﻿Imports System.Data.OleDb

Public Class BDD
    Private _StrConexion As String
    Private _Conexion As OleDbConnection
    Private _Instruccion As OleDbCommand
    Private _Lector As OleDbDataReader

    Public Sub New()
        _StrConexion = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= .\CAMPEONATOS.mdb ;Persist Security Info=True"
        _Conexion = New OleDbConnection(_StrConexion)
    End Sub

    Public Sub Open()
        _Conexion.Open()
    End Sub

    Public Sub Close()
        If (Not _Conexion Is Nothing) Then
            _Conexion.Close()
        End If
    End Sub

    Public Function Insertar(ByVal SQL As String) As Integer
        Dim FilasInsertadas As Integer = 0

        Try
            _Instruccion = New OleDbCommand(SQL, _Conexion)
            ' Me.Open()
            FilasInsertadas = _Instruccion.ExecuteNonQuery()
        Catch ex As Exception
            Debug.WriteLine("Error: " + ex.Message)
            Throw ex
        Finally
            ' Me.Close()
        End Try

        Return FilasInsertadas
    End Function

End Class
